//https://dart.cn/language/#enums

/**
枚举类型的取值范围是一组预定义的值或实例。 */


// 完整定义 Planet 枚举，包含所有行星
enum Planet {
  mercury(planetType: PlanetType.terrestrial, moons: 0, hasRings: false),
  venus(planetType: PlanetType.terrestrial, moons: 0, hasRings: false),
  earth(planetType: PlanetType.terrestrial, moons: 1, hasRings: false),
  mars(planetType: PlanetType.terrestrial, moons: 2, hasRings: false),
  jupiter(planetType: PlanetType.gas, moons: 95, hasRings: true),
  saturn(planetType: PlanetType.gas, moons: 146, hasRings: true),
  uranus(planetType: PlanetType.ice, moons: 27, hasRings: true),
  neptune(planetType: PlanetType.ice, moons: 14, hasRings: true);

  const Planet({
    required this.planetType,
    required this.moons,
    required this.hasRings,
  });

  final PlanetType planetType;
  final int moons;
  final bool hasRings;

  bool get isGiant =>
      planetType == PlanetType.gas || planetType == PlanetType.ice;
}

void main() {
  // 获取水星的信息
  print('Mercury: ${Planet.mercury.planetType}, Moons: ${Planet.mercury.moons}, Has Rings: ${Planet.mercury.hasRings}, Is Giant: ${Planet.mercury.isGiant}');

  // 获取天王星的信息
  print('Uranus: ${Planet.uranus.planetType}, Moons: ${Planet.uranus.moons}, Has Rings: ${Planet.uranus.hasRings}, Is Giant: ${Planet.uranus.isGiant}');

  // 使用已定义的 Planet.earth
  final yourPlanet = Planet.earth;

  if (!yourPlanet.isGiant) {
    print('Your planet is not a "giant planet".');
  }
}